package org.zhadoop.stream.cql.semanticanalyzer.parser.context;

import java.util.List;

import org.zhadoop.stream.cql.DriverContext;
import org.zhadoop.stream.cql.exception.CQLException;
import org.zhadoop.stream.cql.exception.SemanticAnalyzerException;
import org.zhadoop.stream.cql.hooks.SemanticAnalyzeHook;
import org.zhadoop.stream.cql.semanticanalyzer.InsertStatementAnalyzer;
import org.zhadoop.stream.cql.semanticanalyzer.SemanticAnalyzer;
import org.zhadoop.stream.cql.semanticanalyzer.parsecontextwalker.ParseContextWalker;
import org.zhadoop.stream.cql.tasks.LazyTask;
import org.zhadoop.stream.cql.tasks.Task;

/**
 * insert 语句语法解析内容
 * @author zwd
 *
 */
public class InsertStatementContext extends ParseContext {

	private String streamName;

	private SelectStatementContext select;

	@Override
	public String toString() {
		return "INSERT INTO STREAM " + streamName + " " + select.toString();
	}

	public String getStreamName() {
		return streamName;
	}

	public void setStreamName(String streamName) {
		this.streamName = streamName;
	}

	public SelectStatementContext getSelect() {
		return select;
	}

	public void setSelect(SelectStatementContext select) {
		this.select = select;
	}

	@Override
	public Task createTask(DriverContext driverContext, List<SemanticAnalyzeHook> analyzeHooks) throws CQLException {
		Task task = new LazyTask();
		return task;
	}

	@Override
	public SemanticAnalyzer createAnalyzer() throws SemanticAnalyzerException {
		 return new InsertStatementAnalyzer(this);
	}

	@Override
	protected void walkChild(ParseContextWalker walker) {
		walkExpression(walker, select);
	}

}
